/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-09-04
 * Time: 23:18
 */
public class Test87 {
    public static int coinChange(int[] coins, int amount) {
        int INF = 0x3f3f3f3f;
        int n = coins.length;
        int[] dp = new int[amount+1];
        for(int i = 1; i <= amount; i++) {
            dp[i] = INF;
        }
        for(int i = 1; i <= n; i++) {
            for(int j = coins[i-1]; j <= amount; j++) {
                dp[j] = Math.min(dp[j],dp[j-coins[i-1]]+1);
            }
        }
        return dp[amount] == INF ? -1 : dp[amount];
    }
    public static void main(String[] args) {
        int[] coins = {1,2,5};
        int amount = 11;

        int ret = coinChange(coins,amount);
        System.out.println(ret);
    }
}
